<?php 
include_once('jcart/jcart.php');
require_once 'class/control.class.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>Faster Saúde</title>
	
	<script type="text/javascript" src="js/jquery.js"></script>

	<script type="text/javascript" src="js/cufon-yui.js"></script>
	<script type="text/javascript" src="js/Optima_400.font.js"></script>
	
	<script type="text/javascript" src="jcart/js/jcart.min.js"></script>
	
	<link href="css/style.css" 				rel="stylesheet" type="text/css" />
	<link rel="stylesheet" type="text/css" media="screen, projection" href="jcart/css/jcart.css" /> 
	
	<style>
		#jcart{
			position: static;
			width: 100%;
			margin: 0px;
			display: block;	
			-moz-box-shadow: 0px 0px 0px #333333;
   			-webkit-box-shadow: 0px 0px 0px #333333;
    		box-shadow: 0px 0px 0px #333333;
		}
		.tituloG{
			font-size: 42px;
			color: #FFF;	
		}
	</style>
	<script type="text/javascript">
		Cufon.replace('.tituloG');
	</script>
</head>
<body>
<div id="topo" style="height:185px;">
	<div class="centro" >
        <div id="left"><a href="index.php"><img src="imagens/logo.png" vspace="10" /></a></div>
		<div id="right" style="padding-top:30px;">
				<p class="tituloG">Carrinho de compras</p>
		</div>
    </div> 
</div>
<br class="clear" />    
<div id="container" style="margin-top:190px;" class="centro"> 
    <form target="pagseguro" method="post" action="https://pagseguro.uol.com.br/v2/checkout/payment.html">  
        <input type="hidden" name="receiverEmail" value="jarthurfastersaude@hotmail.com">  
        <input type="hidden" name="currency" value="BRL">      
        <!-- Itens do pagamento (ao menos um item é obrigatório) -->  
        <?php 
        	$lista =  $jcart->get_contents();
        	$total = count($lista);
        	for($i = 0;$i < $total;$i++){
        		$st = explode('/',$lista[$i]['name']);
        		
        		$param['id']  = $lista[$i]['id'];
        		$param['cor'] = trim($st[1]);
        		$param['tam'] = trim($st[2]);
        		
        		$obj = new Control('peso','referencias',$param);
        		$obj->Consult();
        		$con = $obj->result->lista;
        		
        		$vlr  = number_format($lista[$i]['subtotal'],2,'.','');
        		$peso = (str_replace(',','.',$con['peso']) * $lista[$i]['qty']);
        		$peso = round($peso,0,PHP_ROUND_HALF_UP);
        		
        		echo '<input type="hidden" name="itemId',$i+1,'" 			value="',$lista[$i]['id'],'">';
        		echo '<input type="hidden" name="itemDescription',$i+1,'" 	value="',$lista[$i]['name'],'">'; 
        		echo '<input type="hidden" name="itemAmount',$i+1,'" 		value="',$vlr,'">';
        		echo '<input type="hidden" name="itemQuantity',$i+1,'" 		value="',$lista[$i]['qty'],'">';
        		echo '<input type="hidden" name="itemWeight',$i+1,'" 		value="',$peso,'">';
        	}
        ?>
        <div id="jcart"><?php $jcart->display_cart();?></div> 
    </form>
</div>
</body>	
</html>